package com.chengwt.dao.impl;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.chengwt.entity.Document;
import com.chengwt.entity.Readinglog;
import com.chengwt.util.HibernateUtil;

public class ReadinglogTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Session session =HibernateUtil.getSession();
		Transaction tx = session.beginTransaction();
		
		try {
			Readinglog rl = new Readinglog();
			rl.setDocumentId(1);
			rl.setUserId(1);
			
			Document d1 = new Document();
			d1.setDocumentName("aaa");
			d1.setDocumentPath("abbb");
			
			Document d2 = new Document();
			d2.setDocumentName("1111");
			d2.setDocumentSummary("dsfdf");
			
			rl.getDocumentSet().add(d1);
			rl.getDocumentSet().add(d2);
			
			session.save(rl);
			
			
			tx.commit();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			HibernateUtil.closeSession();
		}
	}

}
